import {
	stat
} from 'fs'
import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from '../node_modules/vuex-persistedstate/dist/vuex-persistedstate.js'

Vue.use(Vuex)


const store = new Vuex.Store({
	state: {
		"userInfo": {},
		"history": [],
		"systemparameter": [],
		"is_fixed": false
	},

	mutations: {
		SetUserInfo(state, info) {
			state.userInfo = info
		},
		SetHistoryInfo(state, info) {
			state.history = info
		},
		SystemParameter(state, info) {
			state.systemparameter = info
		},
		Setfixed(state, info) {
			state.is_fixed = info
		}
	},
	plugins: [
		// 可以有多个持久化实例  
		createPersistedState({
			key: 'app_config_data', // 状态保存到本地的 key   
			paths: ['userInfo', 'history', 'systemparameter','is_fixed'], // 要持久化的状态，在state里面取，如果有嵌套，可以  a.b.c   
			storage: { // 存储方式定义  
				getItem: (key) => uni.getStorageSync(key), // 获取  
				setItem: (key, value) => uni.setStorageSync(key, value), // 存储  
				removeItem: (key) => uni.removeStorageSync(key) // 删除  
			}
		})
	]
})

export default store